package com.hz.house.controller;


import com.hz.house.bean.entity.SellManBasicInfo;
import com.hz.house.bean.entity.SellManDynamic;
import com.hz.house.common.ResultBean;
import com.hz.house.service.SellManServiceExt;
import com.hz.house.token.CurrentUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 置业顾问主页相关
 */
@RestController
@RequestMapping("/api/v2/sellmanExt")
@Api("置业顾问主页相关")
public class SellManControllerExt {

    @Autowired
    private SellManServiceExt sellManServiceExt;

    @PostMapping("/releaseDyn")
    @ApiOperation("置业顾问发布动态，content标题，imgs图片地址，两者至少填其一")
    public ResultBean releaseDynamic(@RequestBody SellManDynamic dyn) {
        return sellManServiceExt.releaseDynamic(dyn.getContent(),dyn.getImgs(),CurrentUser.getCurrentUserId());
    }

    @GetMapping("/queryDyn")
    @ApiOperation("获取置业顾问动态列表,customerId为置业顾问id，其他用户查看置业顾问动态时需传参,不传代表当期置业顾问查看自己的动态")
    public ResultBean queryDynamic(Integer customerId,Integer page) {
        if (customerId == null)
            customerId = CurrentUser.getCurrentUserId();
        return sellManServiceExt.queryDynamic(customerId,page);
    }

    @GetMapping("/delDyn")
    @ApiOperation("删除置业顾问动态，id为该条动态的主键id")
    public ResultBean delDyn(@RequestParam Integer id) {
        return sellManServiceExt.delDynamic(id,CurrentUser.getCurrentUserId());
    }

    @PostMapping("/modify")
    @ApiOperation("置业顾问申请或修改")
    public ResultBean modifySellMan(@RequestBody SellManBasicInfo pc) {
        pc.setCustomerId(CurrentUser.getCurrentUserId());
        return sellManServiceExt.modifySellMan(pc);
    }

    @PostMapping("/exchangeBuilding")
    @ApiOperation("置业顾问申请或修改")
    public ResultBean exchangeBuilding() {
        return sellManServiceExt.exchangeBuilding(CurrentUser.getCurrentUserId());
    }

    @GetMapping("/getBuilding")
    @ApiOperation("根据名称获取楼盘")
    public ResultBean getBuildingByName(String name) {
        return sellManServiceExt.getBuildingByName(name);
    }

    @GetMapping("/getInfo")
    @ApiOperation("获取置业顾问基本信息")
    public ResultBean getBasicInfo() {
        return sellManServiceExt.getBasicInfo(CurrentUser.getCurrentUserId());
    }

    @GetMapping("/sign")
    @ApiOperation("用户签到")
    public ResultBean sign() {
        return sellManServiceExt.sign(CurrentUser.getCurrentUserId());
    }

    @GetMapping("getSignInfo")
    @ApiOperation("获取用户签到记录以及是否可以签到,year-年，mouth-月，不传默认代表当前月份")
    public ResultBean getSignInfo(Integer year,Integer month) {
        return sellManServiceExt.getSignInfo(CurrentUser.getCurrentUserId(),year,month);
    }

    @GetMapping("/getSysMsg")
    @ApiOperation("获取用户系统消息")
    public ResultBean getSystemMsg(Integer page) {
        return sellManServiceExt.getSystemMsg(CurrentUser.getCurrentUserId(),page);
    }

    @GetMapping("/editMsgRead")
    @ApiOperation("设置系统消息已读,id为当前消息的主键id,不传则设置所有消息为已读")
    public ResultBean editMsgRead(@RequestParam Integer id) {
        return sellManServiceExt.editMsgRead(CurrentUser.getCurrentUserId(),id);
    }

    @GetMapping("/getMyScore")
    @ApiOperation("查询置业顾问总积分、活跃度以及今日加分")
    public ResultBean getAllDays() {
        return sellManServiceExt.getMyScore(CurrentUser.getCurrentUserId());
    }

    @GetMapping("/getMyLpFocus")
    @ApiOperation("查询我关注的楼盘")
    public ResultBean getMyBuildingFocus(Integer page) {
        return sellManServiceExt.getMyBuildingFocus(CurrentUser.getCurrentUserId(),page);
    }

    @GetMapping("/getMyGwFocus")
    @ApiOperation("查询我关注的置业顾问")
    public ResultBean getMySellManFocus(Integer page) {
        return sellManServiceExt.getMySellManFocus(CurrentUser.getCurrentUserId(),page);
    }

    @GetMapping("/myCenter")
    @ApiOperation("我的个人中心")
    public ResultBean myCenter() {
        return sellManServiceExt.myCenter(CurrentUser.getCurrentUserId());
    }

    @GetMapping("/sellManHomePage")
    @ApiOperation("置业顾问主页信息及点赞收藏状态,customerId为要查看的那个置业顾问的customerId")
    public ResultBean getSellManHomePage(@RequestParam Integer customerId) {
        return sellManServiceExt.getSellManHomePage(CurrentUser.getCurrentUserId(),customerId);
    }

    @GetMapping("/queryConsume")
    @ApiOperation("查询置业顾问消费记录")
    public ResultBean queryConsumeRecord(Integer page) {
        return sellManServiceExt.queryConsumeRecord(CurrentUser.getCurrentUserId(),page);
    }
    
    @ApiOperation(value = "获取lpr")
    @GetMapping("/getLPR")
    public Object getLPR() {
    	return this.sellManServiceExt.getLPR();
    }
    
}
